<script setup lang="ts">
import { message } from 'ant-design-vue';

import { useVbenForm } from '#/adapter/form';
import { putSettingPassword } from '#/api/admin/setting';

async function onSubmit(values: Record<string, any>) {
  const { msg } = await putSettingPassword(values);
  message.success(msg);
}

const [PasswordForm] = useVbenForm({
  handleSubmit: onSubmit,
  schema: [
    {
      component: 'InputPassword',
      componentProps: {
        placeholder: '请输入',
      },
      fieldName: 'old_password',
      label: '原始密码',
      rules: 'required',
    },

    {
      component: 'InputPassword',
      componentProps: {
        placeholder: '请输入',
      },
      fieldName: 'password',
      label: '新密码',
      rules: 'required',
    },
    {
      component: 'InputPassword',
      componentProps: {
        placeholder: '请输入',
      },
      fieldName: 're_password',
      label: '重复新密码',
      rules: 'required',
    },
  ],
});
</script>

<template>
  <PasswordForm />
</template>
